//
//  UIDevice+Extension.swift
//  YangFoundation
//
//  Created by yuyang on 2021/12/21.
//

import UIKit

public let screenW = UIScreen.main.bounds.width
public let screenH = UIScreen.main.bounds.height
public let screenWidthRadio = (screenW / 375)
public let screenHeightRadio = (screenH / 667)
public let onePixel = 1.0 / UIScreen.main.scale

public extension UIDevice {
    static var isIphoneXSeries: Bool {
        if UIDevice.current.userInterfaceIdiom != .phone {
            return false
        }
        
        if #available(iOS 11.0, *) {
            if let window = UIApplication.shared.keyWindow,
               window.safeAreaInsets.bottom > CGFloat(0.0) {
                return true
            }
        }
        
        return false
    }
    
    static var navigationBarY: CGFloat {
        return self.isIphoneXSeries ? CGFloat(44.0) : CGFloat(20.0)
        
    }
    
    static var navgationHeight: CGFloat {
        return self.isIphoneXSeries ? CGFloat(88.0) : CGFloat(64.0)
    }
    
    static var topSafeAreaMargin: CGFloat {
        return self.isIphoneXSeries ? CGFloat(44.0) : CGFloat(20.0)
    }
    
    static var bottomSafeAreaMargin: CGFloat {
        return self.isIphoneXSeries ? CGFloat(34.0) : CGFloat(0.0)
    }
}
